import idraw.*;
import geometry.*;
import tester.*;
import java.util.*;
import adraw.Canvas;
import colors.*;

/**
 * Magical Flying Machine With Genie
 * @author Ryan &Adam
 */
class Mfmwg{
  Posn location;
  int fuel;
  int rad = 10;
  
  /**
   * Consructor
   * @param location The position where the Genie is.
   * @param fuel How much fuel the Genie has.
   */
  Mfmwg(Posn location, int fuel) {
    this.location = location;
    this.fuel = fuel;
  }
  /*
   * TEMPLATE:
   * FIELDS:
   * ... this.fuel ...           --int
   * ... this.location ...       --Posn
   * ... this.rad ...            --int
   *
   * METHODS:
   * ... this.drawMfmwg(Canvas c) ...  -- boolean
   * ... this.catchStar() ...          -- Mfmwg
   * ... this.onKeyEvent(String ke) ...-- Mfmwg
   * ... this.onTick() ...             -- Mfmwg
   *
   * METHODS FOR FIELDS:
   * n/a
   */ 
  
  /**
   * Draws the Genie.
   * @param theCanvas
   */
  void drawMfmwg(Canvas theCanvas){
    theCanvas.drawDisk(this.location, this.rad, new Red());
  }
  
  /**
   * Adds fuel to the Genie.
   * @param s
   * @return
   */
  Mfmwg catchStar(Star s){
    return new Mfmwg(this.location, this.fuel + s.span);
  }
  
  /**
   * Changes location of the Genie.
   * @param ke
   */
  void onKeyEvent(String ke){
    if (ke.equals("up")){
      this.location.y = this.location.y - 10; 
    } else {if (ke.equals("down")){
      this.location.y = this.location.y + 10;
    } else {if (ke.equals("left")){
      this.location.x = this.location.x - 10;
    } else {if (ke.equals("right")){
      this.location.x = this.location.x + 10;
    } else{     
    }}}}
  }
  
  /**
   * Adjusts the current ship according to the ticker
   */
  void onTick(){
    fuel = this.fuel - 5;
  }
}